var projectId="";
var fitName="";
var toggleFlag=false;	//为true左侧树隐藏
$(function(){
	//左侧
	$('.nav-one').each(function(){
		var num = $(".nav-one").length;
		$(this).click(function(){
			if($(this).children('img:eq(0)').attr('src').indexOf('selected')>-1)
				retrun;
			$('.foot-nav-b ul li img').each(function(){
				$(this).attr('src','/images/'+$(this).attr('id')+'.png');
			});
			$('.nav-one').each(function(){
			$(this).children('img:eq(0)').attr('src','/images/'+$(this).children('img:eq(0)').attr('id')+'.png');
			});	
			$(this).children('img:eq(0)').attr('src','/images/'+$(this).children('img:eq(0)').attr('id')+'_selected.png');
			var height=0;
			$(this).next('.nav-tow').children('p').each(function(){
				$(this).children('a').css('color','#ffbc4d');
			    height+=$(this).children('a').outerHeight();
			});
			if(height>($('.nav').height()-num*$(".nav-one").outerHeight()));
			height=$('.nav').height()-num*$(".nav-one").outerHeight();
			$(this).next('.nav-tow').height(height);
			$('.nav-tow').hide(500);
			$(this).next(".nav-tow").show(500);
	   	    $(this).addClass("nav-one-select").siblings().removeClass("nav-one-select");
		});
	});
	$('.nav-tow a').each(function(){
		$(this).click(function(){
			$('.nav-tow a').removeClass('active');
			$(this).addClass('active');
		});
	});
   //下方
   $('.foot-nav-b ul li img').each(function(){
		$(this).click(function(){
			$('.nav-one').each(function(){
			   $(this).children('img:eq(0)').attr('src','/images/'+$(this).children('img:eq(0)').attr('id')+'.png');
			});
			$('.nav-tow').hide(500);
			$('.nav-one').removeClass("nav-one-select");
			$('.foot-nav-b ul li img').each(function(){
				$(this).attr('src','/images/'+$(this).attr('id')+'.png');
			});
			$(this).attr('src','/images/'+$(this).attr('id')+'_selected.png');
		});
	});
})


//局部刷新
function changeMain(filename){
	//$.ajaxSetup ({ cache: false });
	if(filename==="maintplan"||filename==="fitness"){
		$("#frameReft").load(filename+".html?projectId="+projectId+"&random="+Math.random(),function(){
			// $('#pagination').jqPaginator(pagination({total:parseInt($("#total").val()),size:parseInt($("#size").val()),currentpage:parseInt($("#page").val()),visibPage:3,pagePath:filename}))
		});		
	}else if(filename.indexOf('?')>0){
		var proId = filename.substring(filename.indexOf('?')+1);
		var name = filename.substring(0,filename.indexOf('?'));
		window.projectId=proId;
		$("#frameReft").load(name+".html?projectId="+proId+"&random="+Math.random());
	}
	else if(filename==="ietm-log"){
		$("#frameReft").load(filename+".html?type=2&random="+Math.random());
	}
	else if(filename==="annotations"||filename==="tags"){
		$("#frameReft").load(filename+".html?projectId="+projectId+"&random="+Math.random());
	}
	else
	$("#frameReft").load(filename+".html?random="+Math.random(),function(){});
	//DM查看注释弹出框链接DM
	if("ietm-home?comment"==filename){}
	//点击过的历史记录
	else{
	if (ietmCurrentPos >= ietmHistoryArr.length - 1){
		ietmHistoryArr.push(filename);
		ietmCurrentPos = ietmHistoryArr.length - 1;
    }else{
    	ietmHistoryArr.splice(ietmCurrentPos + 1, 0, filename);
        ietmCurrentPos = ietmCurrentPos + 1;
    }
	}
}
//适用性
/*function fitness(){
	alert(111);
	  var diag = new $.Zebra_Dialog({
          source: {'iframe': {
          	'id':'fitness',
              'src':'/ietm/fitness',
              'height':400,
          }},
          width:600,
          title:'适用性',
          buttons: ['确定']
      });
}*/